﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NodeBasedSkillEditor.Model.Node.RT
{
    public class Node_Vector2ToScalar_RT : RT_Node
    {
        public RT_SingleValuePort In_Vector2;

        public RT_SingleValuePort Out_X;

        public RT_SingleValuePort Out_Y;

        public Node_Vector2ToScalar_RT(Node_Vector2ToScalar sourceData, RT_DAG parentDag) : base(sourceData, parentDag)
        {
            In_Vector2 = new RT_SingleValuePort(EPortIOType.Input, sourceData.Vector2, this);

            Out_X = new RT_SingleValuePort(EPortIOType.Output, sourceData.X, this);
            Out_X.OnGetValue = GetOutX;
            
            Out_Y = new RT_SingleValuePort(EPortIOType.Output, sourceData.Y, this);
            Out_Y.OnGetValue = GetOutY;
        }

        public AValue GetOutX(DAG_Executor executor)
        {
            var vec2 = In_Vector2.GetValue(executor) as Value_Vector2;
            Out_X.SourceValue.SetScalar(vec2.Value.X);
            return Out_X.SourceValue;
        }

        public AValue GetOutY(DAG_Executor executor)
        {
            var vec2 = In_Vector2.GetValue(executor) as Value_Vector2;
            Out_Y.SourceValue.SetScalar(vec2.Value.Y);
            return Out_Y.SourceValue;
        }
    }
}
